{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6c7a9295",
   "metadata": {},
   "source": [
    "* 时间：2022-10-10/week08\n",
    "* 课程：python\n",
    "* 记录人：yy"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "08c4c97f",
   "metadata": {},
   "source": [
    "## 本周内容\n",
    "> 1.关于字符串的基本结构  \n",
    "> 2.关于字符串的方法及函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dfa55de5",
   "metadata": {},
   "source": [
    "## 1.字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dbf21bed",
   "metadata": {},
   "source": [
    "### 1.1关于字符串的基本内容\n",
    "Single quotes: 'allows embedded \"double\" quotes'\n",
    "\n",
    "Double quotes: \"allows embedded 'single' quotes\"\n",
    "\n",
    "Triple quoted: '''Three single quotes''', \"\"\"Three double quotes\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dc3fbd7c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'spam eggs'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'spam eggs'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0936392f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type('spam eggs'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a867972d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"doesn't\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1883c557",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'doesn\\'t'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7bb3895b",
   "metadata": {},
   "source": [
    "* 三个引号：保留字符串信息的格式信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "51a40eb5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''doesn't'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7df723ee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Usage: thingy [OPTIONS]\n",
      "     -h                        Display this usage message\n",
      "     -H hostname               Hostname to connect to\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\"\"\"\n",
    "Usage: thingy [OPTIONS]\n",
    "     -h                        Display this usage message\n",
    "     -H hostname               Hostname to connect to\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb28f54d",
   "metadata": {},
   "source": [
    "### 1.2[关于字符串的方法及函数](http://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)\n",
    "\n",
    "> 1. 字符串是可以拼接的（字符串的运算）,用+进行字符串之间的拼接  \n",
    "> 2. 字符串是有序的，从第一个字符开始，从0依次往后，可以len（）检查字符串的长度  \n",
    "> 3. 字符串的取值：  \n",
    ">> 1.取单个值 ：从左往右（正数，第一个是0），从右往左（负数，第一个值是-1）  \n",
    ">> 2.取多个值 ：切片的方法，两个值作为取值的区间  \n",
    "> 4. 字符串的方法及函数  \n",
    ">> 1.in查询成员是否存在  \n",
    ">> 2.str.count()查询数量  \n",
    ">> 3.str.isdigit()判断字符串是否是 数字"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "da076262",
   "metadata": {},
   "source": [
    "* 用+进行字符串之间的拼接"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "b017dd26",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_name=[\"小米\",\"小花\",\"小红\",\"小哈\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "33e2ef7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院欢迎小米\n",
      "广州南方学院欢迎小花\n",
      "广州南方学院欢迎小红\n",
      "广州南方学院欢迎小哈\n"
     ]
    }
   ],
   "source": [
    "for i in new_name:\n",
    "    print(\"广州南方学院欢迎\"+i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "931083d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院欢迎小米'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"广州南方学院欢迎\"+\"小米\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "ea0979e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院欢迎小米'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text = '广州南方学院欢迎小米'\n",
    "text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "90a384dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "708ef787",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "string index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [19]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mtext\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m10\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[1;31mIndexError\u001b[0m: string index out of range"
     ]
    }
   ],
   "source": [
    "text[10]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58aa27f4",
   "metadata": {},
   "source": [
    "* len可以检查字符串的长度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "f58a74fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(text)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "77a1c9f2",
   "metadata": {},
   "source": [
    "* 使用切片的方法进行多个值 取值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "b7649caa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'欢迎'"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[6:8]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06ed60a2",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院欢迎小米 (vatues)\n",
    " 0 1 2 3 4 5 6 7 8 9 (index)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ac322dd0",
   "metadata": {},
   "source": [
    "* in 查询成员"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "28f6a127",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'广州' in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "0de5e242",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'北京' in text"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f055a4f2",
   "metadata": {},
   "source": [
    "* str.count() 查询数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "af82ab99",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.count('广州')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6e255ae",
   "metadata": {},
   "source": [
    "* str.isdigit()判断字符串是否是 数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "7061c37d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19\n",
      "19\n"
     ]
    }
   ],
   "source": [
    "print(19)\n",
    "print('19')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "7557965b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19 <class 'int'>\n",
      "19 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "age_li = 19\n",
    "age_wang = '19'\n",
    "print(19,type(age_li))\n",
    "print('19',type(age_wang))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "3b6279cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_wang.isdigit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "9f2a86af",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for /: 'str' and 'int'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [32]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m19\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[38;5;241;43m2\u001b[39;49m\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for /: 'str' and 'int'"
     ]
    }
   ],
   "source": [
    "'19'/2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f5e5424",
   "metadata": {},
   "source": [
    "## 2.有序的数据结构——列表（list）\n",
    "Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. Lists might contain items of different types, but usually the items all have the same type.  \n",
    "Python知道许多复合数据类型，用于将其他值组合在一起。最通用的是列表，它可以写成方括号之间用逗号分隔的值(项)的列表。列表可能包含不同类型的项，但通常所有项都具有相同的类型。\n",
    "\n",
    "> 1.列表的运算法则（参考：有序的数据结构的运算法则表）  \n",
    "> 2.列表的一般方法（要求：全部掌握，并且做总结）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e6fc5e2",
   "metadata": {},
   "source": [
    "### 2.1列表的运算法则"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "424c50e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 字符串存放\n",
    "网二_name = \"李华,小明,李晓华,小花\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "c2201e81",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(网二_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "3ad76fae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串取值，比较麻烦\n",
    "网二_name[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "3deeb2bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'小明'"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "1c77ff32",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李晓华'"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[6:9]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66c0a672",
   "metadata": {},
   "source": [
    "* 对比字符串和列表\n",
    "> 1.字符串是按照字符进行数据取值  \n",
    "> 2.列表是按照元素进行数据取值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "67edeaac",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_name_list = [\"李华\",\"小明\",\"李晓华\",\"小花\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "8c37350b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(网二_name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "db70a003",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "2cd5d5b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['李华', '小明']"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "2593bbeb",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_nage_list = [19,18,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "759d5940",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_nage_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "8b3e8ac8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[19, 18, 19, 20]"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_nage_list[:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "86c4610a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[19, 18, 19, 20, 19, 18, 19, 20, 19, 18, 19, 20]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_nage_list*3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "c387b11d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_nage_list.count(19)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c266d2fc",
   "metadata": {},
   "source": [
    "### 2.2[列表的一般方法 ](https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range)\n",
    "> 1.增加  \n",
    "> 2.删除  \n",
    "> 3.修改  \n",
    "> 4.查询in，count\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "0fff71ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"Mike\",\"Mary\",\"Jan\",\"Jack\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bfc4e84d",
   "metadata": {},
   "source": [
    "* 学习方法\n",
    "> 1.(Tab键) listname. 查看所有方法名称  \n",
    "> 2.help(listname.function)查看其中一个方法的具体操作内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fba99553",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.pop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "ba9572ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "4cf682e8",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"yy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "5a986aa3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'Mary', 'Jan', 'Jack', 'yy']"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "509e5e09",
   "metadata": {},
   "source": [
    "### 课后练习\n",
    "做一个表格，总结列表的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "eae3e81d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['apple', 'banana', 'cherry']\n"
     ]
    }
   ],
   "source": [
    "水果 = [\"apple\", \"banana\", \"cherry\"]\n",
    "print(水果)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f8835eb3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "banana\n"
     ]
    }
   ],
   "source": [
    "水果 = [\"apple\", \"banana\", \"cherry\"]\n",
    "print(水果[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7e3bf67b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['apple', 'mango', 'cherry']\n"
     ]
    }
   ],
   "source": [
    "水果 = [\"apple\", \"banana\", \"cherry\"]\n",
    "水果[1] = \"mango\"\n",
    "print(水果)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c42d88d7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apple\n",
      "banana\n",
      "cherry\n"
     ]
    }
   ],
   "source": [
    "水果 = [\"apple\", \"banana\", \"cherry\"]\n",
    "for x in 水果:\n",
    "  print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "2e472588",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "水果 = [\"apple\", \"banana\", \"cherry\"]\n",
    "print(len(水果))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "81c7906c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['apple', 'banana', 'cherry', 'orange']\n"
     ]
    }
   ],
   "source": [
    "水果 = [\"apple\", \"banana\", \"cherry\"]\n",
    "水果.append(\"orange\")\n",
    "print(水果)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9946fc53",
   "metadata": {},
   "source": [
    "* 列表的方法\n",
    "> 1.可以通过引用索引号来访问列表项  \n",
    "> 2.负索引表示从末尾开始，-1 表示最后一个项目，-2 表示倒数第二个项目，依此类推  \n",
    "> 3.可以通过指定范围的起点和终点来指定索引范围  \n",
    "> 4.需更改特定项目的值，引用索引号  \n",
    "> 5.检查项目是否存在,用in  \n",
    "> 6.使用 for 循环遍历列表项  \n",
    "> 7.确定列表中有多少项，使用 len() 方法\n",
    "> 8.将项目添加到列表的末尾，使用 append() 方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "2a84840d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "0ce5f165",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>方法</th>\n",
       "      <th>描述</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>append()</td>\n",
       "      <td>在列表的末尾添加一个元素</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>clear()</td>\n",
       "      <td>删除列表中的所有元素</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>copy()</td>\n",
       "      <td>返回列表的副本</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>count()</td>\n",
       "      <td>返回具有指定值的元素数量。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>extend()</td>\n",
       "      <td>将列表元素（或任何可迭代的元素）添加到当前列表的末尾</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>index()</td>\n",
       "      <td>返回具有指定值的第一个元素的索引</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>insert()</td>\n",
       "      <td>在指定位置添加元素</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>pop()</td>\n",
       "      <td>删除指定位置的元素</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>remove()</td>\n",
       "      <td>删除具有指定值的项目</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>reverse()</td>\n",
       "      <td>颠倒列表的顺序</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>sort()</td>\n",
       "      <td>对列表进行排序</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           方法                          描述\n",
       "0    append()                在列表的末尾添加一个元素\n",
       "1     clear()                  删除列表中的所有元素\n",
       "2      copy()                     返回列表的副本\n",
       "3     count()               返回具有指定值的元素数量。\n",
       "4    extend()  将列表元素（或任何可迭代的元素）添加到当前列表的末尾\n",
       "5     index()            返回具有指定值的第一个元素的索引\n",
       "6    insert()                   在指定位置添加元素\n",
       "7       pop()                   删除指定位置的元素\n",
       "8    remove()                  删除具有指定值的项目\n",
       "9   reverse()                     颠倒列表的顺序\n",
       "10     sort()                     对列表进行排序"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://www.w3school.com.cn/python/python_lists.asp\")[0]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
